//
//  KVNHouseCommentTableViewCell.m
//  Test1
//
//  Created by KelvinYeung on 15/8/9.
//  Copyright (c) 2015年 KelvinYeung. All rights reserved.
//

#import "KVNHouseCommentTableViewCell.h"


@interface KVNHouseCommentTableViewCell()



@end


@implementation KVNHouseCommentTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    [self initSubViews];
    return self;
}


- (void) initSubViews{
    _avatarImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"account"]];
    _avatarImageView.layer.cornerRadius = 25;
    _avatarImageView.clipsToBounds = YES;
    [self.contentView addSubview:_avatarImageView];
    _avatarImageView.translatesAutoresizingMaskIntoConstraints = NO;
    
    
    _userNameLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_userNameLabel];
    _userNameLabel.font = [UIFont systemFontOfSize:14];
    _userNameLabel.textColor = [UIColor redColor];
    _userNameLabel.translatesAutoresizingMaskIntoConstraints = NO;
    
    
    _commentStarView = [[KVNCommentStarView alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    [self.contentView addSubview:_commentStarView];
    _commentStarView.translatesAutoresizingMaskIntoConstraints = NO;
    
    
    _commentContentLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_commentContentLabel];
    _commentContentLabel.font = [UIFont systemFontOfSize:16];
    //_commentContentLabel.numberOfLines = 0;
    _commentContentLabel.translatesAutoresizingMaskIntoConstraints = NO;
    
    
    _commentTimeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_commentTimeLabel];
    _commentTimeLabel.textColor = [UIColor grayColor];
    _commentTimeLabel.font = [UIFont systemFontOfSize:14];
    _commentTimeLabel.translatesAutoresizingMaskIntoConstraints = NO;
    
    
    //layout
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_avatarImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1 constant:10]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_avatarImageView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1 constant:10]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_avatarImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0 constant:50]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_avatarImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0 constant:50]];
    
    
    //_userNameLabel
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_userNameLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:_avatarImageView attribute:NSLayoutAttributeRight multiplier:1 constant:10]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_userNameLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_avatarImageView attribute:NSLayoutAttributeTop multiplier:1 constant:5]];

    //_commentStarView
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentStarView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_userNameLabel attribute:NSLayoutAttributeBottom multiplier:1 constant:2]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentStarView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:_avatarImageView attribute:NSLayoutAttributeRight multiplier:1 constant:10]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentStarView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1 constant:-10]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentStarView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:_avatarImageView attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
    
    
    
    //_commentContentLabel
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentContentLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_avatarImageView attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentContentLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1 constant:10]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentContentLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1 constant:-10]];
    
    
    //_commentTimeLabel
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentTimeLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_commentContentLabel attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentTimeLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1 constant:10]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentTimeLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1 constant:-10]];
    //[self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_commentTimeLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1 constant:-10]];
    
    
    
    
    
    
    
}


@end
